﻿using System.Linq.Expressions;

namespace Mg.ExpressionParser.Parser
{
    class NewArrayExpressionParser : BaseExpressionParser<NewArrayExpression>
    {
        protected override SqlPack In(NewArrayExpression expression, SqlPack sqlPack)
        {
            sqlPack += "(";

            foreach (Expression expressionItem in expression.Expressions)
            {
                ExpressionParserProvider.In(expressionItem, sqlPack);
            }

            if (sqlPack.Sql[sqlPack.Sql.Length - 1] == ',')
            {
                sqlPack.Sql.Remove(sqlPack.Sql.Length - 1, 1);
            }

            sqlPack += ")";

            return sqlPack;
        }
    }
}
